# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
pkgname=py3-openant
pkgver=1.3.1
pkgrel=1
pkgdesc="Python library to communicate with ANT-FS compliant devices"
url="https://github.com/Tigge/openant"
arch="noarch"
license="MIT"
depends="python3 py3-pyserial py3-usb"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest-xdist"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/Tigge/openant/archive/v$pkgver/openant-$pkgver.tar.gz"
builddir="$srcdir/openant-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest -n auto
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	rm -r "$pkgdir"/usr/lib/python3.*/site-packages/openant/tests

	rm -r "$pkgdir"/usr/lib/python3.*/site-packages/ant/tests

	install -Dm644 "$builddir"/resources/42-ant-usb-sticks.rules -t "$pkgdir"/usr/lib/udev/rules.d/
}

sha512sums="
579f0edcdc3d30058ef9d6ecbb60e143c3c47a7bff6212a80fb0f315387eac183c2dbe4c779e78c38d6b767242cd5824a78520b006e583bc55bf5be01f7e3ad1  py3-openant-1.3.1.tar.gz
"
